package com.zijin;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.sql.ResultSet;
import java.util.List;

/**
 * Hello world!
 *
 */
public class App2
{
    public static void main( String[] args )
    {
        SqlSessionFactory ssf=new SqlSessionFactoryBuilder().build(
                App.class.getClassLoader().getResourceAsStream("mybatisConf.xml"));
//打开一个会话 ，会话会占用资源，不需要时要关闭
        SqlSession ss=ssf.openSession();
        //namespace+id
        //查询一个
        Object obj=ss.selectOne("com.zijin.Dao.DeptMapper.selectDeptById");
        System.out.println(obj);
        //查询多个会返回list集合
        List<Object> list=ss.selectList("com.zijin.Dao.DeptMapper.selectAllDept");
        for(Object o:list){
            System.out.println(o);
        }
        //关闭会话
        ss.close();

        System.out.println(ssf);
    }
}

